package com.miya.demo.common.enums;

import java.util.function.Function;

/**
 * 脱敏枚举
 *
 * @author 54011
 * @date 2023/07/20
 */
public enum DataMaskEnum {

    /*名称脱敏*/
    USERNAME(s->s.replaceAll("(\\S)\\S(\\S*)","$1*$2")),
    /*手机号脱敏*/
    PHONE(s->s.replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2")),
    /*地址脱敏*/
    ADDRESS(s->s.replaceAll("(\\S{3})\\S{2}(\\S*)\\S{2}","$1****$2****"))
    ;
    private Function<String,String> function;
    DataMaskEnum(Function<String, String> function) {
        this.function = function;
    }
    public Function<String, String> function(){
        return  this.function;
    }
}
